public class MyCircularQueue {

    int[] array;
    int front;
    int tail;

    public MyCircularQueue(int k) {
        this.array = new int[k+1];
    }

    public boolean enQueue(int value) {
        if(isFull()){
            return false;
        }
        this.array[this.tail] = value;
        this.tail = (this.tail+1)%this.array.length;
        return true;
    }

    public boolean deQueue() {
        if(isEmpty()){
            return false;
        }
        this.array[this.front] = 0;
        this.front = (this.front+1)%this.array.length;
        return true;
    }

    public int Front() {
        if(isEmpty()){
            return -1;
        }else {
            return this.array[this.front];
        }
    }

    public int Rear() {
       if(isEmpty()){
           return -1;
       }else{
           int index = (this.tail==0)?(this.array.length-1):(this.tail-1);
           return this.array[index];
       }
    }

    public boolean isEmpty() {
        return this.front==this.tail;
    }

    public boolean isFull() {
        return (this.tail+1)%this.array.length==this.front;

    }
}

/**
 * Your MyCircularQueue object will be instantiated and called as such:
 * MyCircularQueue obj = new MyCircularQueue(k);
 * boolean param_1 = obj.enQueue(value);
 * boolean param_2 = obj.deQueue();
 * int param_3 = obj.Front();
 * int param_4 = obj.Rear();
 * boolean param_5 = obj.isEmpty();
 * boolean param_6 = obj.isFull();
 */